﻿Imports FuncClasses
Imports System.ComponentModel

Public Class CustomPlugIn
    Implements Biller.IPlugIn2, INotifyPropertyChanged

    Protected Sub NotifyPropertyChanged(info As [String])
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    End Sub

    Public Event PropertyChanged(sender As Object, e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Private _isenabled As Boolean = False
    Private parent As Biller.Window1
    Private _user As User

    Public Sub New(ByRef _parent As Biller.Window1)
        parent = _parent
        '_parent.UpdateChecker.AddFile(New UpdateFileInfo("Sammelrechnung.addin", "Erweiterung zum Zusammenführen von Lieferscheinen zu einer Rechnung", Version))
    End Sub

    Public ReadOnly Property Author As String Implements Biller.IPlugIn2.Author
        Get
            Return "Igor Lückel"
        End Get
    End Property

    Public Sub Disable() Implements Biller.IPlugIn2.Disable
        _isenabled = False
        NotifyPropertyChanged("IsEnabled")
    End Sub

    Public Sub Initialize() Implements Biller.IPlugIn2.Initialize
        _isenabled = True
        NotifyPropertyChanged("IsEnabled")
    End Sub

    Public ReadOnly Property IsEnabled As Boolean Implements Biller.IPlugIn2.IsEnabled
        Get
            Return _isenabled
        End Get
    End Property

    'Public Property MainWindow As Biller.Window1

    Public ReadOnly Property Name As String Implements Biller.IPlugIn2.Name
        Get
            Return "Sammelrechnung"
        End Get
    End Property

    Public Sub NewOrderControl(ByRef control As Biller.AuftragControl) Implements Biller.IPlugIn2.NewOrderControl
        If IsEnabled Then
            control.TabControl.Items.Add(New RibbonTab(Me, control.CompleteAuftrag, _user, control))
        End If
    End Sub

    Public ReadOnly Property Version As Decimal Implements Biller.IPlugIn2.Version
        Get
            Return 0.6
        End Get
    End Property

    Public Property Database As IDatabase Implements Biller.IPlugIn2.Database

    Public ReadOnly Property GUID As Guid Implements Biller.IPlugIn2.GUID
        Get
            Return New Guid("46afb4e8-f943-45ab-b448-975bf87a54c5")
        End Get
    End Property

    Public ReadOnly Property UserRequest As nHibernate.Models.UserPreviewModel Implements Biller.IPlugIn2.UserRequest
        Get
            Return New nHibernate.Models.UserPreviewModel With {.CanReadOrder = True}
        End Get
    End Property

    Public Sub SetUser(user As User) Implements Biller.IPlugIn2.SetUser
        _user = user
    End Sub

    Public Sub SetViewToArticle(ByRef control As Biller.AuftragControl)
        control.TabControl.SelectedIndex = 2
    End Sub
End Class
